<template>
  <div>
    <div>
      <van-nav-bar
          title=""
          left-text="返回"
          left-arrow
          @click-left="onClickLeft"
      />
    </div>


    <van-row>
      <van-col span="2"></van-col>
      <van-col span="20">
        <div style="margin-top: 200px;">
          <van-uploader :after-read="afterRead">
            <van-image round width="10rem" height="10rem" :src="headurl" />
          </van-uploader>
        </div>
        <div style="margin-top: 30px;">
          <van-button @click="tzLogin" round block type="primary">请登录</van-button>
        </div>
      </van-col>
      <van-col span="2"></van-col>
    </van-row>
  </div>
</template>

<script>
export default {
  setup() {
    const onClickLeft = () => history.back();
    return {
      onClickLeft,
    };
  },
  data() {
    return {
      headurl: "https://img.yzcdn.cn/vant/cat.jpeg"
    }
  },


  methods: {
    tzLogin() {
      this.$router.push("/login");
    },
    afterRead(file) {
      var that = this;
      console.log(file);
      const forms = new FormData();
      forms.append("file", file.file);
      this.axios.post("oss/uploadHeadImg" ,forms, {
        headers: {
          'Conent-Type': 'multipart/form-data',
        },
      }).then((res) => {
        if (res.data.code == 200) {
          that.headurl = res.data.data;
        }
      }).catch((e) => {

      })
    }
  }
}
</script>

<style>

</style>
